<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="root">
        <!--遍历数组-->
        <button @click.once="add">添加一个老刘</button>
        <h2>人员列表</h2>
        <ul>
            <li v-for="(p,index) in persons":key="p.id">
                {{p.name}}-{{p.age}}
                <input type="text" >
            </li>

        </ul>
        <!--遍历对象-->
        <h2>汽车对象</h2>
        <ul>
            <li v-for="(a,index) in car":key="index">
                {{a}}-{{index}}

            </li>

        </ul>


    </div>
    <script src="../js/vue.js"></script>
    <script>
            Vue.config.productionTip=false//阻止vue启动时产生提示
            new Vue({
                 el: "#root",
                 data:{
                      persons:[
                          {id:'001',name:'张三',age:18},
                          {id:'002',name:'李四',age:18},
                          {id:'003',name:'王五',age:18}
                      ],
                     car:{
                         name:"奥迪A8",
                         price:"70万",
                         color:"黑色"
                     }
                    },
                 methods:{//方法
                     add(){
                         const p={id:'004',name:'老刘',age:40}
                         this.persons.unshift(p)
                     }

                 },
                 computed:{//计算

                 },
                 watch:{//监视

                 }
             })
    </script>
</body>
</html>